package com.idp.common.model;

import com.alibaba.fastjson2.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;

/**
 * 登录数据
 * @author king
 */
@ApiModel(description = "登录信息")
public class LoginInfo implements UserDetails {

	private static final long serialVersionUID = 1L;

	/** token */
	@ApiModelProperty("token")
	private String token;
	/** 主键ID */
	@ApiModelProperty("用户id")
	private String id;
	/** 用户名 */
	@ApiModelProperty("账号")
	private String account;
	/** 手机号 */
	@ApiModelProperty("手机号")
	private String phone;
	/** 姓名 */
	@ApiModelProperty("名称")
	private String name;
	/** 用户类型: 1PC系统用户，2移动端用户 */
	@ApiModelProperty("用户类型: 1PC系统用户，2移动端用户")
	private String userType;
	@ApiModelProperty("认证过期时间")
	private long expireTime;

	@JSONField(serialize = false)
	@JsonIgnore
	@ApiModelProperty(hidden = true)
	private String pwd;

	public String getToken() {
		return token;
	}
	public void setToken(String token) {
		this.token = token;
	}
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getAccount() {
		return account;
	}
	public void setAccount(String account) {
		this.account = account;
	}
	public String getPhone() {
		return phone;
	}
	public void setPhone(String phone) {
		this.phone = phone;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getUserType() {
		return userType;
	}
	public void setUserType(String userType) {
		this.userType = userType;
	}
	public long getExpireTime() {
		return expireTime;
	}
	public void setExpireTime(long expireTime) {
		this.expireTime = expireTime;
	}
	public String getPwd() {
		return pwd;
	}
	public void setPwd(String pwd) {
		this.pwd = pwd;
	}

	@JSONField(serialize = false)
	@JsonIgnore
	@Override
	public Collection<? extends GrantedAuthority> getAuthorities() {
		return null;
	}

	@JSONField(serialize = false)
	@JsonIgnore
	@Override
	public String getPassword() {
		return this.pwd;
	}

	@JSONField(serialize = false)
	@JsonIgnore
	@Override
	public String getUsername() {
		return this.account;
	}

	@JSONField(serialize = false)
	@JsonIgnore
	@Override
	public boolean isAccountNonExpired() {
		return true;
	}

	@JSONField(serialize = false)
	@JsonIgnore
	@Override
	public boolean isAccountNonLocked() {
		return true;
	}

	@JSONField(serialize = false)
	@JsonIgnore
	@Override
	public boolean isCredentialsNonExpired() {
		return true;
	}

	@JSONField(serialize = false)
	@JsonIgnore
	@Override
	public boolean isEnabled() {
		return true;
	}
}
